home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / ultmtpch.lha / UPS / Sources / DPatch.s < prev    next >
Text File  |  1995-09-17  |  10KB  |  371 lines

  1. ;TOSAAAABGJFAAAACFHJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPPPPMDPC
  2.  
  3. ;My first patcher (c) Wizard/GPS 27/07/1994
  4.  
  5. ;Converted to Ultimate Patch System format by SAA/Glenz PointS in 1995.
  6.  
  7. ;I decided to patch DOS function DELETE in order to prevent user-non-alowed
  8. ;actions. Hehehe... c00l. Every time OS wanna delete something, requester
  9. ;pops up and ask for our permission. c00l. :)
  10.  
  11. ;I've just figured out that some memory should be allocated.
  12. ;Silly me, no wonder it crashed after some brain transplants in memory. ;)
  13. ;I'll fix it as sonn as... hm. Soon enough.
  14.  
  15. ;Date 02/08/1994 Wow! That's something I call Soon. I surprised even myself.
  16. ;Well, se far so good. Code is fixed not to crash system...
  17. ;I don't expect any fee - just spare my life. ;) [v1.0]
  18.  
  19. ;Date 03/08/1994 Great! I've just got back from, hm... swiming session. ;)
  20. ;I should do it more often. As soon as I got back, idea just poped out!
  21. ;This proggy had a really nasty bug - it crashed every time when trying
  22. ;to deallocate allocated memory. I didn't know where the bug was at the
  23. ;time, but few secs ago I realized something very stupid. I passed
  24. ;deallocate memory pointer to address of variable instead of passing it
  25. ;to value stored in veriable (I mixed this sentence, but instead of
  26. ;move X,d0, I did something like move #X,d0. Got it? :->).
  27. ;Won't happen again. ;)
  28.  
  29. ;Last decision - when user is trying to get out from the patcher and
  30. ;restore old Delete() what then? I decided ti call old Delete() at
  31. ;this moment which means that at the time user has selected killing
  32. ;patcher, old Delete() function is active and called through my proggy.
  33. ;Got it? Exit from patcher = call Delete() for the first time in
  34. ;new 'life'. :->
  35.  
  36. ;Date 05/08/1994 New option added. This proggy was unable to show name
  37. ;of the file that should be deleted. I fixed it today. [v1.1]
  38.  
  39. ;Date 09/08/1994 I've just added something new, at SAA's request. If you
  40. ;have deleted <NAME> file DPatch'll let <NAME.info> deletes automatically.
  41. ;This ability includes also <NAME.info...info> files NOT even supported
  42. ;by Workbench! :-> Yea, but I thought it would be nice... ;) [v1.2]
  43.  
  44. ;Date 09/08/1994 Fixed incompatibility problems with DOPUS. Read doc
  45. ;for more info. There's a kind of bug now - if you choose not to delete
  46. ;certain file, you'll be unable to delete it right after this delete
  47. ;call. You'll have to delete something else first, just to remove
  48. ;old name from buffer. Sorry for this. [v1.2]
  49.  
  50. ;Date 11/08/1994 I've missed something. Oooops. This proggy doesn't
  51. ;work with OLD dos.library (ver$ < 39.00). I built in checkpoint for
  52. ;this, but it seems I forgot stopping the program. Silly me, again. ;)
  53.  
  54.     incdir    "include:"
  55.     include    "libs/exec.i"
  56.     include    "libs/dos.i"
  57.     include    "libs/reqtools.i"
  58.     incdir    "ups:"
  59.     include    "ups.i"
  60.  
  61.     SECTION    aa,code_p
  62.  
  63. Start    moveq    #0,d0
  64.     rts
  65. .end    blk.b    32-(.end-Start)
  66.     dc.l    pfsControlLong
  67.     dc.l    0            ; pointer to next patcher
  68.     dc.l    0            ; pointer to prev patcher
  69.     dc.l    UPSMainVersion        ; minimum version of UPS to start
  70.     dc.l    UPSMainVersion        ; version of UPS which was used
  71.                     ; while patcher was developed
  72.     dc.l    PatcherName        ; pointer to name of patcher
  73.     dc.w    0,0            ; version
  74.     dc.l    CoderName        ; pointer to name of programmer
  75.     dc.l    VerString        ; pointer to $VER: string
  76.     dc.l    PatcherIDString        ; listview entry
  77.     dc.l    pfsDisableable        ; flags
  78.     dc.l    0            ; status of flags
  79. execbase
  80.     dc.l    0            ; exec base
  81. intbase    dc.l    0            ; intuition base
  82. gadtbase
  83.     dc.l    0            ; gadtools base
  84. dosbase    dc.l    0            ; dos base
  85. gfxbase    dc.l    0            ; graphics base
  86. cxbase    dc.l    0            ; commodities base
  87. laybase    dc.l    0            ; layers base
  88. upsbase    dc.l    0            ; UPS lib base
  89.     dc.l    0            ; pointer to init routine
  90.     dc.l    0            ; pointer to exit routine
  91.     dc.l    0            ; pointer to prefs routine
  92.     dc.l    0            ; pointer to cx keys to call prefs rout
  93.     dc.l    Resources        ; pointer to structure of requested
  94.                         ; opened resources
  95.     dc.l    Patch1            ; pointer to structure for patches
  96.     dc.l    pls1            ; pointer to pls structure
  97.     dc.l    0            ; pointer to main UPS msg port
  98.     dc.l    0            ; pointer to rexx port
  99.     dc.l    0            ; pointer to pxs structure
  100.     dc.l    0,0,0
  101.     dc.l    pfsControlLong
  102.     dc.l    Start            ; pointer to the beginning of struct
  103.  
  104. PatcherIDString
  105. PatcherName
  106.     dc.b    'DPatch',0
  107.     even
  108. CoderName
  109.     dc.b    'Goran Paulin',0
  110.     even
  111. VerString
  112.     dc.b    '$VER: DPatch V2.0',0
  113.     even
  114.  
  115.     cnop    0,4
  116.  
  117. Resources
  118.     dc.l    0            ; pointer to next entry
  119.     dc.l    0            ; pointer to previous entry
  120.     dc.l    rt_Library        ; type of resource
  121.     dc.l    100            ; resource id
  122.     dc.l    0            ; flags
  123.     dc.l    res1name        ; pointer to name of resource
  124. res1base
  125.     dc.l    0            ; base of opened resource
  126.     dc.l    0            ; version, if needed
  127.     blk.l    8            ; ...to put in data regs
  128.     dc.l    0            ; user open rout for user type
  129.     dc.l    0            ; user close rout for user type
  130.     dc.l    0            ; pointer to name for user type
  131.     dc.l    0,0
  132.  
  133. res1name
  134.     dc.b    'dos.library',0
  135.     cnop    0,4
  136.  
  137.  
  138.  
  139. Patch1
  140.     dc.l    0            ; pointer to next patch
  141.     dc.l    0            ; pointer to prev patch
  142.     dc.l    100            ; priority, less runs first
  143.     dc.l    Start            ; pointer to parent Patcher
  144.     dc.l    Patch1ID        ; listview entry
  145.     dc.l    Patch1purpose        ; pointer to purpose string
  146.     dc.l    100            ; id of resource to be patched
  147.     dc.l    mpsDisableable        ; flags
  148.     dc.l    0            ; status of flags
  149.     dc.l    -72            ; offset to change
  150.     dc.l    MyDelete        ; pointer to new routine
  151. old    dc.l    0            ; pointer to old routine
  152.     dc.l    0            ; pointer to pns structure
  153.     dc.l    0            ; notified when enabled/disabled
  154.     dc.l    0            ; install rout for user type
  155.     dc.l    0            ; uninstall rout for user type
  156.     dc.l    0            ; pointer to init routine
  157.     dc.l    0            ; pointer to exit routine
  158.     dc.l    pls1            ; pointer to pls structure
  159.     dc.l    0,0,0,0
  160.  
  161.  
  162. Patch1ID
  163. pls1ID
  164.     dc.b    'DeleteFile()',0        ; 27
  165.     even
  166. Patch1purpose
  167.     dc.b    'improving',0            ; 16
  168.     cnop    0,4
  169.  
  170.  
  171.  
  172. pls1    dc.l    0            ; pointer to next link
  173.     dc.l    0            ; pointer to prev link
  174.     dc.l    pls1ID            ; listview string
  175.     dc.l    0            ; pointer to prefs routine
  176.     dc.l    plsDisableable        ; flags
  177.     dc.l    0            ; status
  178.     dc.l    Patch1
  179.     dc.l    0
  180.  
  181.     cnop    0,4
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188. MyDelete
  189.     movem.l    d0-d7/a0-a6,-(a7)
  190.  
  191. ; Test if something's trying to delete same file.
  192. ; In this case we simply use previous answer stored in Choice.
  193.  
  194.     move.l    d1,a0            ; new file name
  195.     lea    FileName(pc),a1        ; old file name
  196. CompareSame
  197.     move.b    (a0)+,d0
  198.     cmpi.b    #'a',d0            ; uppercase conversion (!)
  199.     blt.b    LeaveSame1            ; why?
  200.     cmpi.b    #'z',d0            ; Extras!=EXTRAS >REMEMBER!<
  201.     bgt.b    LeaveSame1
  202.     sub.b    #32,d0            ; a -> A, z -> Z
  203. LeaveSame1
  204.     move.b    (a1)+,d2
  205.     cmpi.b    #'a',d2            ; uppercase conversion (!)
  206.     blt.b    LeaveSame2            ; why?
  207.     cmpi.b    #'z',d2            ; Extras!=EXTRAS >REMEMBER!<
  208.     bgt.b    LeaveSame2
  209.     sub.b    #32,d2            ; a -> A, z -> Z
  210. LeaveSame2
  211.     cmpi.b    #0,d0            ; test new file name end
  212.     beq.s    TestMatchSame
  213.     cmp.b    d0,d2            ; COMPARE names
  214.     beq.s    CompareSame        ; if ONLY one char is wrong -> skip
  215.     bra.s    NotSameFile        ; doesn't match!
  216. TestMatchSame
  217.     cmpi.b    #0,d2            ; test old file name end
  218.     bne.s    NotSameFile        ; doesn't match!
  219. FileMatch
  220.     bra.w    OldChoice
  221.     
  222. NotSameFile
  223.     lea    PopUp(pc),a0        ; default = pop up = 0
  224.     move.b    #1,(a0)
  225.  
  226. ; Check if something's trying to delete appropriate .info file
  227. ; Delete it automatically in this case!
  228.  
  229. AddInfo
  230.     lea    FileName(pc),a0        ; form NAME.info,$0
  231.     clr.l    d0            ; prepare d0
  232.     move.b    NameLen(pc),d0
  233.     subq.l    #1,d0
  234.     adda.l    d0,a0
  235.     move.b    #'.',(a0)+
  236.     move.l    #'info',(a0)+
  237.     move.b    #0,(a0)            ; file name formed
  238.  
  239.     move.l    d1,a0            ; new file name
  240.     lea    FileName(pc),a1        ; old file name
  241. Compare
  242.     move.b    (a0)+,d0
  243.     cmpi.b    #'a',d0            ; uppercase conversion (!)
  244.     blt.b    Leave1            ; why?
  245.     cmpi.b    #'z',d0            ; Extras!=EXTRAS >REMEMBER!<
  246.     bgt.b    Leave1
  247.     sub.b    #32,d0            ; a -> A, z -> Z
  248. Leave1
  249.     move.b    (a1)+,d2
  250.     cmpi.b    #'a',d2            ; uppercase conversion (!)
  251.     blt.b    Leave2            ; why?
  252.     cmpi.b    #'z',d2            ; Extras!=EXTRAS >REMEMBER!<
  253.     bgt.b    Leave2
  254.     sub.b    #32,d2            ; a -> A, z -> Z
  255. Leave2
  256.     cmpi.b    #0,d0            ; test new file name end
  257.     beq.s    TestMatch
  258.     cmp.b    d0,d2            ; COMPARE names
  259.     beq.s    Compare            ; if ONLY one char is wrong -> skip
  260.     bra.s    Count            ; doesn't match!
  261. TestMatch
  262.     cmpi.b    #0,d2            ; test old file name end
  263.     bne.s    Count            ; doesn't match!
  264. Matching
  265.     lea    Erase(pc),a0
  266.     tst.b    (a0)
  267.     beq.s    Count            ; previous file NOT erased
  268.     lea    PopUp(pc),a0
  269.     clr.b    (a0)            ; requester Pops Up!
  270.  
  271. Count
  272.     clr.l    d2            ; prepare for counting
  273.     move.l    d1,a0            ; get file name address (d1)
  274.     lea    FileName(pc),a1
  275. MoveName
  276.     addq.l    #1,d2            ; increase counter
  277.     move.b    (a0),(a1)+        ; copy file name
  278.     cmpi.b    #0,(a0)+        ; in requester structure
  279.     bne.s    MoveName
  280. StoreLen
  281.     lea    NameLen(pc),a0
  282.     move.b    d2,(a0)            ; remember char num!
  283. SetUp
  284.     move.l    4,a6            ; exec base
  285.     move.l    #38,d0            ; Lib Ver$ion
  286.     lea    reqname(pc),a1
  287.     jsr    OpenLibrary(a6)
  288.     lea    reqbase(pc),a1        ; PC relative!
  289.     move.l    d0,(a1)
  290.     beq.b    NoReqTools
  291.  
  292. TestPopUp
  293.     lea    PopUp(pc),a0
  294.     tst.b    (a0)            ; IF PopUp!=0...
  295.     beq.s    CallOldDelete        ; don't pop up! Call old delete
  296.  
  297. Menu
  298.     move.l    reqbase(pc),a6        ; PopUp==1 pop up!
  299.     lea    Text1(pc),a1
  300.     lea    Text2(pc),a2
  301.     lea    tags(pc),a0
  302.     sub.l    a3,a3
  303.     sub.l    a4,a4
  304.     jsr    rtEZRequestA(a6)
  305.     lea    Choice(pc),a0
  306.     move.l    d0,(a0)
  307. OldChoice
  308. ;    cmpi.l    #2,d0
  309. ;    beq.b    RestoreOldDelete
  310.     cmpi.l    #1,d0
  311.     beq.b    CallOldDelete
  312.     lea    Erase(pc),a0
  313.     move.b    #0,(a0)            ; clear ERASED flag (NOT ERASED!)
  314. CloseReqLib
  315.     move.l    $4.w,a6
  316.     move.l    reqbase(pc),a1
  317.     tst.l    (a1)            ; if not opened, don't close! :->
  318.     beq.s    NoReqTools
  319.     jsr    CloseLibrary(a6)
  320. NoReqTools
  321.     movem.l    (a7)+,d0-d7/a0-a6
  322.     addq.l    #4,a7
  323.     rts
  324.  
  325. ;RestoreOldDelete
  326. ;    move.l    4,a6
  327. ;    move.l    dosbase(pc),a1        ; PC relative mode
  328. ;    move.l    #-72,a0            ; is a MUST here!!!
  329. ;    move.l    delete(pc),d0
  330. ;    jsr    -420(a6)        ; set old Delete()
  331.  
  332. ;    bra    CloseReqLib        ; I cut it! Call old Delete()!
  333.  
  334. CallOldDelete
  335.     movem.l    (a7)+,d0-d7/a0-a6    ; we need PURE code!
  336. ;dirty    jsr    $00000000        ; d0n't do it at home! ]:->
  337.     move.l    #return,-(a7)
  338.     move.l    old,-(a7)
  339.     rts
  340. return    movem.l    d0-d7/a0-a6,-(a7)    ; as PURE as we can get
  341.     lea    Erase(pc),a0
  342.     move.b    #1,(a0)            ; set ERASED flag
  343.     bra.b    CloseReqLib
  344.  
  345. PatchedData
  346.  
  347. Text1    dc.b    "BIG BROTHER IS WATCHIN' YOU",10
  348.     dc.b    "Wizard/GlenzPointS (c) 1994",10
  349.     dc.b    "SAA/GlenzPointS, 1995.",10,10
  350.     dc.b    "Intruder wanna delete:",10
  351. FileName
  352.     ds.b    80
  353.     dc.b    0
  354.  
  355. Text2    dc.b    "I'll take my risk!|Noooo! I'm innocent!",0
  356.     even
  357.  
  358. tags    dc.l    $80000000+22,1<<2
  359.     dc.l    0
  360. reqbase    dc.l    0
  361. Choice    dc.l    0            ; don't request! Use old choice!
  362. Erase    dc.b    1            ; erased flag (first erased!)
  363. NameLen    dc.b    1            ; file name length
  364.                     ; IF !=1 (==0) point will apear!
  365. PopUp    dc.b    0            ; IF ==1 pops up
  366.     even
  367. reqname    dc.b    'reqtools.library',0
  368.     
  369.  
  370. End
  371.